package com.boarsoft.boar.batch.demo.flow;

import java.util.HashMap;
import java.util.Map;

import com.boarsoft.flow.core.bean.ForkHandler;

public class DemoFlowBatchFork1 implements ForkHandler {

	@SuppressWarnings("unchecked")
	@Override
	public Map<String, Object> fork(String key, Object data, Throwable throwable) {
		Map<String, Object> pm = (Map<String, Object>) data;
		int pageCount = (Integer) pm.get("pageCount");
		
//		for (String m:pm.keySet()) {
//			System.out.println("ForkHandler接收key: " + m + "  value: " + pm.get(m));
//		}
		System.out.println("ForkHandler接收map: " + pm);
		
		Map<String, Object> rm = new HashMap<String, Object>();
		for (int p = 0; p < pageCount; p++) {
			Map<String, Object> m = new HashMap<String, Object>();
			m.putAll(pm);
			m.put("pageNo", new Integer(p));
			rm.put("p".concat(String.valueOf(p)), m);
		}
		for (String m:rm.keySet()) {
			System.out.println("ForkHandler返回key: " + m + "  value: " + rm.get(m));
			Map<String, Object> valueMap = (Map<String, Object>) rm.get(m);
		}
		return rm;
	}
}
